import Vue from 'vue'
import Vuex from 'vuex'

//1.导入插件
import VuexPersistence from 'vuex-persist'
//2. 创建对象进行配置
const vuexLocal = new VuexPersistence({
    storage: window.localStorage,//配置存储介质，默认持久化到本地存储中
})

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    token:"",
    user:{},
  },
  mutations: {
    doLogin(state,data) {
      this.state.token = data.token
      this.state.user = data
    }
  },
  actions: {

  },
  grtters: {

  },

  //引入插件：持久化
  plugins: [vuexLocal.plugin]//引入插件
})
